package com.example.houseman.service.impl;

import com.example.houseman.entity.TbRoomReservation;
import com.example.houseman.mapper.TbRoomReservationMapper;
import com.example.houseman.service.ITbRoomReservationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.org.dto.RoomReservationDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 预约房源表 服务实现类
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-30
 */
@Service
public class TbRoomReservationServiceImpl extends ServiceImpl<TbRoomReservationMapper, TbRoomReservation> implements ITbRoomReservationService {


    @Autowired
    private TbRoomReservationMapper roomReservationMapper;


    @Override
    public List<TbRoomReservation> selects(RoomReservationDto roomReservationDto) {
        return roomReservationMapper.selects(roomReservationDto);
    }

    @Transactional
    @Override
    public boolean update(Integer status, String[] ids) {
        try {
            for (String id : ids) {
                roomReservationMapper.update(status, id);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }
}
